run_estimations=false
run_simulations=false
generate_output=true
export test_size=false

python_files=(
    "scripts/run_estimations.py"
    "scripts/run_simulations.py"
    "scripts/run_simulations_binaryevents.py"
    "scripts/summary_stats.py"
    "scripts/online_appendix_notification_behavior.py"
    "scripts/online_appendix_summary_stats_Q1.py"
    "scripts/online_appendix_summary_stats_voluntary.py"
    "scripts/additional_reduced_form.py"
    "scripts/estimated_parameters_output.py"
    "scripts/simulations_binaryevents.py"
    "scripts/classifier_precision.py"    
    "scripts/simulated_summary_stats.py"
    "scripts/simulations_binaryevents_long.py"
    "scripts/simulated_summary_stats_long.py"
    "scripts/simulations_output.py"
    "scripts/balance_statistics.py"
    "scripts/block_analysis.py"
)

for file in "${python_files[@]}"; do
    if [ "$file" = "scripts/run_estimations.py" ]; then
      if [ "$run_estimations" = true ] ; then
        echo "Running $file..."
        python "$file"
      fi
    elif [ "$file" = "scripts/run_simulations.py" ] || [ "$file" = "scripts/run_simulations_binaryevents.py" ] ; then
      if [ "$run_simulations" = true ] ; then
        echo "Running $file..."
        python "$file"
      fi
    else
      if [ "$generate_output" = true ] ; then
        echo "Running $file..."
        python "$file"
      fi
    fi
    if [ $? -ne 0 ]; then
        echo "Error occurred while running $file. Exiting..."
        exit 1
    fi
done
